package com.sh.data.engine.web.webapi.controller.api;

import com.sh.data.engine.application.model.dto.api.DataApiCallResponse;
import com.sh.data.engine.application.service.api.DataApiCallApplicationService;
import com.sh.data.engine.domain.annotation.LogExecution;
import com.sh.data.engine.domain.annotation.userlog.Business;
import com.sh.data.engine.domain.annotation.userlog.EngineOperation;
import com.sh.data.engine.web.webapi.controller.base.response.RestResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@RequestMapping("/dataApiCall")
@Tag(name = "数据服务-API调用示例", description = "数据服务-API调用示例API")
public class DataApiCallController {

    @Autowired
    private DataApiCallApplicationService dataApiCallApplicationService;

    @GetMapping("/getDemoUrlDetail")
    @Operation(summary = "API调用示例")
//    @ApiVersion(group = ApiVersionConstant.V_20210630)
//    @AuthorityAnnotation(menuId = MenuEnumNew.APIDY, readWriteStatus = 0)
    public RestResponseEntity<DataApiCallResponse> getDemoUrlDetail() {
        var result = dataApiCallApplicationService.getDemoUrlDetail();
        return RestResponseEntity.success(result);
    }

    @Operation(summary = "重置userToken")
    @PostMapping("/resetUserToken")
    @LogExecution(operation = EngineOperation.DATA_API_RESET_TOKEN, business = Business.数据服务)
//    @Log(
//        business = Business.数据服务,
//        operation = Operation.DATA_API_RESET_TOKEN)
//    @AuthorityAnnotation(menuId = MenuEnumNew.WDAPI, readWriteStatus = 1)
    public RestResponseEntity<Boolean> resetUserToken(String password) {
        var result = dataApiCallApplicationService.resetUserToken(password);
        return RestResponseEntity.success(result);
    }
}
